package com.wing.sell.strategy;

import cn.hutool.core.collection.CollectionUtil;
import com.wing.sell.model.request.DeliveryRecordForm;
import com.wing.sell.model.response.OrderSkuDetailSearchVo;

import java.util.List;

/**
 * @Description: 规定了支付记录细节的流程，在其中选择具体的支付策略，为controller提供支付接口
 * @Project: szgc-enterprise-coding
 * @Package: com.wing.sell.strategy.AbstractGenerateOrderService
 * @Date: 2024/12/16 10:06
 * @Author: heZhou
 * @Version: 1.0
 */
public abstract class AbstractGenerateSelOrderService implements SelOrderGenerateStrategy{

    protected String orderType;

    /**
     * 生成交付记录
     *
     * @param type 类型
     * @param deliveryRecordForm 入参
     */
    public Integer generateSelOrder(String type, DeliveryRecordForm deliveryRecordForm) {
        this.orderType = type;
        boolean generateOrder = isGenerateOrder(type);
        if (generateOrder) {
            Integer i = generateOrderResult(deliveryRecordForm);
            if (i != null && i>0) {
                return i;
            }
        }
        return 0;
    }

    /**
     * 查询销售交付记录
     *
     * @param type 类型
     * @param orderId 入参
     */
    public List<OrderSkuDetailSearchVo> getSelOrderList(String type,Long orderId,Long warehouseId) {
        this.orderType = type;
        boolean generateOrder = isGenerateOrder(type);
        if (generateOrder) {
            List<OrderSkuDetailSearchVo> detailBy = getDetailBy(orderId,warehouseId);
            if (CollectionUtil.isNotEmpty(detailBy)) {
                return detailBy;
            }
        }
        return null;
    }
}
